/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include "Saver.h"
#include "Object.h"
#include <Gluck.h>
#include <Converter.h>

namespace liba
{
namespace xml
{

const converter::Sequence<char> SaverTraits<char>::header( "<?xml version=\"1.0\"?>\n\n" );
const converter::Sequence<char> SaverTraits<char>::finish( ">\n" );
const converter::Sequence<char> SaverTraits<char>::node_start( "<" );
const converter::Sequence<char> SaverTraits<char>::empty_node_finish( "/>\n" );
const converter::Sequence<char> SaverTraits<char>::node_finish( "</" );
const converter::Sequence<char> SaverTraits<char>::attr_value_begin( "=\"" );
const converter::Sequence<char> SaverTraits<char>::attr_value_apos_begin( "='" );
const converter::Sequence<char> SaverTraits<char>::quote_alias( "&quote;" );

const converter::Sequence<wchar_t> SaverTraits<wchar_t>::header( L"<?xml version=\"1.0\"?>\n\n" );
const converter::Sequence<wchar_t> SaverTraits<wchar_t>::finish( L">\n" );
const converter::Sequence<wchar_t> SaverTraits<wchar_t>::node_start( L"<" );
const converter::Sequence<wchar_t> SaverTraits<wchar_t>::empty_node_finish( L"/>\n" );
const converter::Sequence<wchar_t> SaverTraits<wchar_t>::node_finish( L"</" );
const converter::Sequence<wchar_t> SaverTraits<wchar_t>::attr_value_begin( L"=\"" );
const converter::Sequence<wchar_t> SaverTraits<wchar_t>::attr_value_apos_begin( L"='" );
const converter::Sequence<wchar_t> SaverTraits<wchar_t>::quote_alias( L"&quote;" );

//bool SaverBase::save_attribute_internal_correct_quote( const std::string & name, const char * attr_begin, const char * attr_end )
//{
//	if( !std::char_traits<char>::find( attr_begin, attr_end - attr_begin, SaverTraits<char>::QUOTE ) )
//		return save_attribute_internal( name, attr_begin, attr_end );
//	if( !std::char_traits<char>::find( attr_begin, attr_end - attr_begin, SaverTraits<char>::APOS ) )
//		return save_attribute_internal_apos( name, attr_begin, attr_end );
//	std::string new_attr;
//	for( const char * c = attr_begin; c != attr_end; ++c )
//		if( *c != SaverTraits<char>::QUOTE )
//			new_attr.append( 1, *c );
//		else
//			new_attr.append( SaverTraits<char>::quote_alias.begin(), SaverTraits<char>::quote_alias.end() );
//	return save_attribute_internal( name, new_attr.begin(), new_attr.end() );
//}
//
//bool SaverBase::save_attribute_internal_correct_quote( const WString & name, const wchar_t * attr_begin, const wchar_t * attr_end )
//{
//	if( !std::char_traits<wchar_t>::find( attr_begin, attr_end - attr_begin, SaverTraits<wchar_t>::QUOTE ) )
//		return save_attribute_internal( name, attr_begin, attr_end );
//	if( !std::char_traits<wchar_t>::find( attr_begin, attr_end - attr_begin, SaverTraits<wchar_t>::APOS ) )
//		return save_attribute_internal_apos( name, attr_begin, attr_end );
//	WString new_attr;
//	for( const wchar_t * c = attr_begin; c != attr_end; ++c )
//		if( *c != SaverTraits<wchar_t>::QUOTE )
//			new_attr.append( 1, *c );
//		else
//			new_attr.append( SaverTraits<wchar_t>::quote_alias.begin(), SaverTraits<wchar_t>::quote_alias.end() );
//	return save_attribute_internal( name, new_attr.begin(), new_attr.end() );
//}

} // namespace xml
} // namespace liba

